﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using AmazonDynamoDBStub.Models;

namespace AmazonDynamoDBStub.EntityFramework.Mapping
{
    public class DynamoDBAttributeMap : EntityTypeConfiguration<DynamoDBAttribute>
    {
        public DynamoDBAttributeMap()
        {
            this.HasKey(t => new { t.TableName, t.RowId, t.AttributeName });

            this.Property(t => t.RowId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            this.Property(t => t.AttributeValue).IsRequired();

            this.HasRequired(t => t.DynamoDBTable).WithMany(t => t.DynamoDBAttributes).WillCascadeOnDelete();
        }
    }
}
